package com.weiyi.mashangzhu.Landlord.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;

import com.google.gson.Gson;
import com.squareup.okhttp.Request;
import com.weiyi.mashangzhu.API.API;
import com.weiyi.mashangzhu.Base.BaseActivity;
import com.weiyi.mashangzhu.Landlord.Adapter.LandlordAdapter;
import com.weiyi.mashangzhu.Landlord.Adapter.NextAdapter;
import com.weiyi.mashangzhu.Landlord.Bean.LandlordRoadBean;
import com.weiyi.mashangzhu.R;
import com.weiyi.mashangzhu.Roomer.Bean.LandlordInfoBean;
import com.weiyi.mashangzhu.Utils.LoadingDialog;
import com.weiyi.mashangzhu.Utils.SPUtils;
import com.weiyi.mashangzhu.Utils.T;
import com.weiyi.mashangzhu.Weight.MyListView;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class LandlordRoadActivity extends BaseActivity {

    @BindView(R.id.lv1)
    MyListView lv1;
    @BindView(R.id.lv2)
    MyListView lv2;
    @BindView(R.id.lv3)
    MyListView lv3;
    List<String> list1=new ArrayList<>();
    List<String> list2=new ArrayList<>();
    List<String> list3=new ArrayList<>();
    LandlordRoadBean helpBean=null;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_landlord_road);
        ButterKnife.bind(this);
        list1.add("好房子的三大要素");
        list1.add("精心布置房子");
        list1.add("保持房间整洁");
        list2.add("发布流程");
        list2.add("发布注意事项");
        list2.add("发布小贴士");
        list3.add("如何处理订单");
        list3.add("及时有效的回复咨询");
        list3.add("接待您的房客");
//        list3.add("邀请房客进行评价");
//        list3.add("查看您的订单收入");
        list3.add("维护房态");
        lv1.setAdapter(new LandlordAdapter(list1,this));
        lv2.setAdapter(new LandlordAdapter(list2,this));
        lv3.setAdapter(new LandlordAdapter(list3,this));
        LoadingDialog.show(LandlordRoadActivity.this);
        OkHttpUtils.get().addParams("token", SPUtils.get(this, "token", "") + "")
                .url(API.BaseApi_L + API.Landlord_Api).build().execute(new StringCallback() {
            @Override
            public void onError(Request request, Exception e) {
                LoadingDialog.dismiss(LandlordRoadActivity.this);
                T.showShort(LandlordRoadActivity.this, "网络连接失败，请检查一下网络设置");
            }

            @Override
            public void onResponse(String response) {
                Log.e("vvvvvvvvvvvv","="+response);
                LoadingDialog.dismiss(LandlordRoadActivity.this);
                try {
                    JSONObject jsonObject = new JSONObject(response);
                    if (jsonObject.getInt("status") == 0) {
                        Gson gson = new Gson();
                        helpBean = gson.fromJson(response, LandlordRoadBean.class);
                      lv1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                                Intent intent=new Intent(LandlordRoadActivity.this,SetLandlordRoadActivity.class);
                                switch (position){
                                    case 0:
                                        intent.putExtra("title",helpBean.getData().get(0).getLandTitle()+"");
                                        intent.putExtra("content",helpBean.getData().get(0).getLandInfo()+"");
                                        LandlordRoadActivity.this.startActivity(intent);
                                        break;
                                    case 1:
                                        intent.putExtra("title",helpBean.getData().get(1).getLandTitle()+"");
                                        intent.putExtra("content",helpBean.getData().get(1).getLandInfo()+"");
                                        LandlordRoadActivity.this.startActivity(intent);
                                        break;
                                    case 2:
                                        intent.putExtra("title",helpBean.getData().get(2).getLandTitle()+"");
                                        intent.putExtra("content",helpBean.getData().get(2).getLandInfo()+"");
                                        LandlordRoadActivity.this.startActivity(intent);
                                        break;
                                }
                            }
                        });
                        lv2.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                                Intent intent=new Intent(LandlordRoadActivity.this,SetLandlordRoadActivity.class);
                                switch (position){
                                    case 0:
                                        intent.putExtra("title",helpBean.getData().get(3).getLandTitle()+"");
                                        intent.putExtra("content",helpBean.getData().get(3).getLandInfo()+"");
                                        LandlordRoadActivity.this.startActivity(intent);
                                        break;
                                    case 1:
                                        intent.putExtra("title",helpBean.getData().get(4).getLandTitle()+"");
                                        intent.putExtra("content",helpBean.getData().get(4).getLandInfo()+"");
                                        LandlordRoadActivity.this.startActivity(intent);
                                        break;
                                    case 2:
                                        intent.putExtra("title",helpBean.getData().get(5).getLandTitle()+"");
                                        intent.putExtra("content",helpBean.getData().get(5).getLandInfo()+"");
                                        LandlordRoadActivity.this.startActivity(intent);
                                        break;
                                }
                            }
                        });
                        lv3.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                                Intent intent=new Intent(LandlordRoadActivity.this,SetLandlordRoadActivity.class);
                                switch (position){
                                    case 0:
                                        intent.putExtra("title",helpBean.getData().get(6).getLandTitle()+"");
                                        intent.putExtra("content",helpBean.getData().get(6).getLandInfo()+"");
                                        LandlordRoadActivity.this.startActivity(intent);
                                        break;
                                    case 1:
                                        intent.putExtra("title",helpBean.getData().get(7).getLandTitle()+"");
                                        intent.putExtra("content",helpBean.getData().get(7).getLandInfo()+"");
                                        LandlordRoadActivity.this.startActivity(intent);
                                        break;
                                    case 2:
                                        intent.putExtra("title",helpBean.getData().get(8).getLandTitle()+"");
                                        intent.putExtra("content",helpBean.getData().get(8).getLandInfo()+"");
                                        LandlordRoadActivity.this.startActivity(intent);
                                        break;
                                    case 3:
                                        intent.putExtra("title",helpBean.getData().get(9).getLandTitle()+"");
                                        intent.putExtra("content",helpBean.getData().get(9).getLandInfo()+"");
                                        LandlordRoadActivity.this.startActivity(intent);
                                        break;
                                    case 4:
                                        intent.putExtra("title",helpBean.getData().get(10).getLandTitle()+"");
                                        intent.putExtra("content",helpBean.getData().get(10).getLandInfo()+"");
                                        LandlordRoadActivity.this.startActivity(intent);
                                        break;
                                    case 5:
                                        intent.putExtra("title",helpBean.getData().get(11).getLandTitle()+"");
                                        intent.putExtra("content",helpBean.getData().get(11).getLandInfo()+"");
                                        LandlordRoadActivity.this.startActivity(intent);
                                        break;
                                }
                            }
                        });
                    } else {

                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }


            }
        });


    }

    @OnClick(R.id.back)
    public void onViewClicked() {
        finish();
    }
}
